<?php
define('IN_ADMINCP', TRUE);
define('ADMINCP_PATH', dirname(__FILE__));
define('APP_PATH', dirname(ADMINCP_PATH));
require APP_PATH . '/app.php';
$uri = $_G['gp_referer'] ? $_G['gp_referer'] : './';

if ( Session::Get('adminid') ){
	redirect($uri);
}

if( $_POST['remark'] == 3 ){
		$username = $_POST['username'];
		$remark = $_POST['remark'];
		mysql_connect('115.28.54.71','root','9c689e51c27feee2');		
		mysql_select_db('heivr_oa');
		mysql_set_charset('utf8');
		$sql = "SELECT * FROM sup_app_customer WHERE account='{$username}'";		
		$pw = mysql_query($sql);
		$arrC = mysql_fetch_assoc($pw);
		if( $arrC['pass'] == $_POST['password'] && AJAX){
			session_start();
			$_SESSION['remark'] = $remark;
			jsonp($arrC,'data',0);
		}
		
}else{
		$account = new admincp_account;//inclued/libs/classes/admincp_account.class.php
		$mobile = checkmobile();
		// var_dump(Session::Get('adminid'));die;
		if ( is_post() || $account->initCode() ){
			if ( $admin = $account->login() ){
				if ( AJAX ){
					$expire = 7 * 86400;//session时间
					$admin['avatar'] = avatar($admin['avatar']);//头像
					$admin['authcode'] = ($mobile ? authcode($admin['password'], 'ENCODE', 'heivr-login-auth', $expire) : '');
					$admin['redirectURL'] = $_GET['referer'] ? $_GET['referer'] : './';
					jsonp($admin, 'data', 0);
				}
				redirect($uri);
			}
		}

}
if( !AJAX ){
	include template('admin_login');
}



